package edu.wit.system.controller;


import edu.wit.common.web.PageResult;
import edu.wit.common.web.Result;
import edu.wit.system.domain.dto.AffairsApplyWorkflowDto;
import edu.wit.system.domain.vo.AffairsApplyWorkflowExamineVo;
import edu.wit.system.service.AffairsApplyWorkflowCompanyService;
import edu.wit.system.service.AffairsApplyWorkflowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 *
 *
 * @author lee
 * 微信端的流程申请接口--------------------------------目前小程序端应该只有申请列表端口，审批端口
 */
@RestController
@RequestMapping("/sys/app/affairsApplyWorkflow")
@Api(tags = "流程申请")
@Validated
public class AppAffairsApplyWorkflowController {
    @Autowired
    private AffairsApplyWorkflowService affairsApplyWorkflowService;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private AffairsApplyWorkflowCompanyService affairsApplyWorkflowCompanyService;

//    /**
//     * 我的申请列表
//     */
//    @ApiOperation(value = "我的申请列表",httpMethod = "GET")
//    @ApiImplicitParams({
//    	@ApiImplicitParam(name = "pageNum",value = "页码",required = true,dataType = "Integer",paramType = "form",defaultValue = "1"),
//		@ApiImplicitParam(name = "pageSize",value = "每页数量",required = true,dataType = "Integer",paramType = "form",defaultValue = "10"),
//        @ApiImplicitParam(name="orderByColumn" ,value="排序行",dataType = "String",paramType = "query"),
//        @ApiImplicitParam(name="isAsc" ,value="排序的方向 desc 或者 asc",dataType = "String",paramType = "query"),
//        @ApiImplicitParam(name = "applyUserId",value = "流程申请人id",required = true,dataType = "String")
//    })
//    @GetMapping("/getApplyList")
//    public PageResult<AffairsApplyWorkflowDto> getApplyList(@RequestParam @ApiIgnore Map<String, Object> params){
//        System.out.println("我的流程申请列表获取");
//       return affairsApplyWorkflowService.getApplyList(params);
//    }

    /**
     * 审核------小程序审核
     */
    @ApiOperation(value = "审核",httpMethod = "POST")
    @PostMapping("/examine")
    // @Log(title = "审核")
    public Result<Boolean> examine(@RequestBody @Valid AffairsApplyWorkflowExamineVo affairsApplyWorkflowExamineVo,@RequestParam String examineId){
        System.out.println("小程序我的流程审核获取");
        affairsApplyWorkflowService.examine(affairsApplyWorkflowExamineVo,examineId);
        return Result.success(true, "审核成功");
    }

    @ApiOperation(value = "多个审核",httpMethod = "POST")
    @PostMapping("/multipleExamine")
    // @Log(title = "审核")
    public Result<Boolean> multipleExamine(@RequestBody @Valid List<AffairsApplyWorkflowExamineVo> affairsApplyWorkflowExamineVos,@RequestParam String examineId){
        System.out.println("我的流程审核(多个审批)获取-------小程序端");
        affairsApplyWorkflowService.multipleExamine(affairsApplyWorkflowExamineVos,examineId);
        return Result.success(true, "审核成功");
    }


    /**
     * 我的审核列表---------小程序审核列表
     */
    @ApiOperation(value = "我的审核列表",httpMethod = "GET")
    @ApiImplicitParams({
    	@ApiImplicitParam(name = "pageNum",value = "页码",required = true,dataType = "Integer",paramType = "form",defaultValue = "1"),
		@ApiImplicitParam(name = "pageSize",value = "每页数量",required = true,dataType = "Integer",paramType = "form",defaultValue = "10"),
        @ApiImplicitParam(name="orderByColumn" ,value="排序行",dataType = "String",paramType = "query"),
        @ApiImplicitParam(name="isAsc" ,value="排序的方向 desc 或者 asc",dataType = "String",paramType = "query"),
        @ApiImplicitParam(name = "examineUserId",value = "审查人员id",required = true,dataType = "String")
    })
    @GetMapping("/getExamineList")
    public PageResult<AffairsApplyWorkflowDto> getExamineList(@RequestParam @ApiIgnore Map<String, Object> params){
        System.out.println("我的审批列表获取");
       return affairsApplyWorkflowService.getExamineList(params);
    }
//
//    /**
//     * 信息
//     */
//    @ApiOperation(value = "详细",httpMethod = "GET")
//    @ApiImplicitParams({
//    	@ApiImplicitParam(name = "id",value = "ID",required = true,dataType = "Long",paramType = "form"),
//    })
//    @GetMapping("/info")
//    public Result<AffairsApplyWorkflowDto> info(@RequestParam("applyId") Long applyId){
//        System.out.println("我的流程详细获取");
//        AffairsApplyWorkflowDto affairsApplyWorkflowDto = affairsApplyWorkflowService.getById(applyId);
//        return Result.success(affairsApplyWorkflowDto, "操作成功");
//    }
//
//    /**
//     * 申请
//     */
//    @ApiOperation(value = "申请",httpMethod = "POST")
//    @PostMapping("/apply")
//   // @Log(title = "申请")
//    public Result<Boolean> apply(@RequestBody(required = false) @Valid AffairsApplyWorkflowVo affairsApplyWorkflowVo){
//        System.out.println("我的流程申请");
//        System.out.println("==================affairsApplyWorkflowVo="+affairsApplyWorkflowVo);
//		affairsApplyWorkflowService.apply(affairsApplyWorkflowVo);
//        return Result.success(true, "申请成功");
//    }
//
//    /**
//     * 撤销
//     */
//    @ApiOperation(value = "撤销",httpMethod = "POST")
//   // @Log(title = "撤销")
//    @GetMapping("/cancel")
//    public Result<Boolean> cancel(@RequestParam("applyId") Long applyId){
//        System.out.println("我的流程撤销获取");
//    	affairsApplyWorkflowService.cancel(applyId);
//        return Result.success(true, "撤销成功");
//    }

//
//    /**
//     * 月工资统计页面 获取指定劳务公司的申请流程信息
//     */
//    @ApiOperation(value = "月工资统计页面 获取指定劳务公司的申请流程信息",httpMethod = "GET")
//    @GetMapping("/getCompanyApplyList/{companyId}")
//    public R getCompanyApplyList(@PathVariable Long companyId){
//        System.out.println("月工资统计页面 获取指定劳务公司的申请流程信息");
//        List<AffairsApplyWorkflowCompany> affairsApplyWorkflowCompanyList=affairsApplyWorkflowCompanyService.selectByCompanyId(companyId+"");
//        return R.ok().data("affairsApplyWorkflowCompanyList",affairsApplyWorkflowCompanyList);
//    }

}
